#ifndef STREAMWRITERBOX_H_JM_20121206
#define STREAMWRITERBOX_H_JM_20121206

// ## jm4bbx
#include "../RootBox.h"
#include "../../common_bbx/tables/BoxDataTable.h"
//#include "../../common_bbx/sharedBoxData/BinaryOperationArguments.h"

// ## c++
#include <ostream>


namespace jm4bbx {

	
	class StreamWriterBox : public RootBox {
	public:
		static const  groupType INPUT_GROUP;
		static const  columnType INPUT_COLUMN;
		static const  inType IN_ARC;
		//static const char* OUTPUT_FORM_PARAM_NAME;
		//static const char* FORM_PRINT_FIRST;
		//static const char* FORM_PRINT_SECOND;
		//static const char* FORM_PRINT_BOTH;

		struct OutputStream {
			virtual bool open() = 0;
			virtual bool close() = 0;
			virtual OutputStream& operator<<(const std::string& out) = 0;
		};


		StreamWriterBox(const BoxParamPack& pack);
		virtual ~StreamWriterBox() {}

		virtual void initImpl() override;
		//virtual void syncMachEtwas() override;

		virtual OutputStream& getOutputStream() = 0;

	protected:
		//std::string format_;

		void wait4Receive() {
			receive(IN_ARC, INPUT_GROUP);
		}

		//std::ostream& write(std::ostream& stream, BoxDataTable* t, size_t row, 
		//	const char* lineEnd = "\n");
	};	


} // namespace jm4bbx

#endif
